package com.fun.seckill.controller;

import com.fun.seckill.service.IUserService;
import com.fun.seckill.vo.LoginVo;
import com.fun.seckill.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@Controller
@RequestMapping()
@Slf4j
public class LoginController {

	@Autowired(required = false)
	private IUserService userService;

	@RequestMapping("/")
	public String toLogin(){
		return "login";
	}

	@RequestMapping("/doLogin")
	@ResponseBody
	public RespBean doLogin(@Valid LoginVo loginVo, HttpServletRequest request, HttpServletResponse response){
		return userService.doLogin(loginVo,request,response);
	}

}